package com.jiutong.meipengdai.http.present;

import android.content.Context;

import com.jiutong.meipengdai.entity.BaseRespond;
import com.jiutong.meipengdai.entity.GatheringListRespond;
import com.jiutong.meipengdai.http.model.interfaces.BaseBiz;
import com.jiutong.meipengdai.http.model.requests.MyAccountRequest;
import com.jiutong.meipengdai.http.subscribers.ProgressSubscriber;
import com.jiutong.meipengdai.http.subscribers.SubscriberOnNextListener;

import java.util.HashMap;

/**
 * Created by suxi on 2017/6/27.
 */

public class GatheringPresent{

    private final Context mContext;
    private final BaseBiz mBiz;
    private final MyAccountRequest myAccountRequest;

    public GatheringPresent(Context context, BaseBiz biz){
        this.mContext = context;
        this.mBiz = biz;
        myAccountRequest = new MyAccountRequest();
    }


    public void getGatheringList() {

        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<GatheringListRespond>() {
            @Override
            public void onNext(GatheringListRespond subjects) {
                mBiz.onSuccess(subjects);
            }

            @Override
            public void onError(Throwable e) {
                mBiz.onError(e);
            }
        };

        HashMap<String, Object> fieldsMap = new HashMap<>();
        myAccountRequest.getGatheringList(new ProgressSubscriber(onNextListener, mContext), fieldsMap);
    }
}
